<<<<<<< HEAD
// pages/course/index.js
const app = getApp()
const $api = require("../../api/course").API
const $banner = require("../../api/banner").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    bannerList:[],
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    typeList:[],
    courseList:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
    t.getKeyValueByKeyType()
    t.getBannerByOwnerShip()
    t.getCourseList()
    // t.getSuitCourseList()
  },

  // 跳转课程分类
  gototype(e){
    var t = this
    wx.navigateTo({
      url:'/course/pages/type/index?type='+e.currentTarget.dataset.type
    })
  },
  gotoinfo(e){
    var t = this
    wx.navigateTo({
      url:'/course/pages/info/index?id='+e.currentTarget.dataset.id
    })
  },
  // 获取排序类型
  getKeyValueByKeyType(){
    var t = this,
    data = {
      dict_type:"CourseType"
    }
    var typeList = wx.getStorageSync('coursetypelist')
    if(typeList){
      t.setData({
        typeList:typeList
      })
      return false
    }
   $api.getKeyValueByKeyType(data).then(res=>{
     console.log(res)
     wx.setStorageSync('coursetypelist', res.data)
     t.setData({
      typeList:res.data
     })
   })
  },
   // 获取推荐列表
   getCourseList(){
    var t = this,
    data={
      pageNo:1,
    }
    $api.getRecommendCourseList(data).then(res=>{
      console.log(res)
      t.setData({
        courseList:res.data
      })
    })
   },
   // 获取适合课程列表
  getSuitCourseList(){
    var t = this,
    data = {
      member_id:wx.getStorageSync('user').member_id
    }
    $api.getSuitCourseList(data).then(res=>{
      console.log(res)
    })
  },
  gotocoursesearch(){
    var t = this
    wx.navigateTo({
      url: '/pages/course/search/index',
    })
  },
  // banner
  getBannerByOwnerShip(){
    var t = this,
    data = {
        banner_ownership:2,
    }
    $banner.getBannerByOwnerShip(data).then(res=>{
        console.log(res.data)
        t.setData({
            bannerList:res.data.detail_list,
            interval:res.data.banner_refresh
        })
    })
},
=======
// pages/course/index.js
const app = getApp()
const $api = require("../../api/course").API
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bannerList:[
      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong.com%2F86%2F10%2F01300000184180121920108394217.jpg&refer=http%3A%2F%2Fa2.att.hudong.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1618052049&t=d82f74883ea57c4f3bccd08094b65672",
      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong.com%2F27%2F81%2F01200000194677136358818023076.jpg&refer=http%3A%2F%2Fa2.att.hudong.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1618051500&t=e57d74ec397c1830c7e17f1040e4e8f0",
      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong.com%2F27%2F81%2F01200000194677136358818023076.jpg&refer=http%3A%2F%2Fa2.att.hudong.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1618051500&t=e57d74ec397c1830c7e17f1040e4e8f0",
    ],
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    typeList:[],
    courseList:[
      {
        "img":"https://img01.yzcdn.cn/vant/apple-1.jpg",
        "title":"标题奥术大师多多多多多多多多多多多多多多多多多多多多多多多多多多多多",
        "content":"奥术大师大所大所打扫打扫多aaaaaaaaaaa挨打是大奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥"
      },{
        "img":"https://img01.yzcdn.cn/vant/apple-1.jpg",
        "title":"标题奥术大师多多多多多多多多多多多多多多多多多多多多多多多多多多多多",
        "content":"奥术大师大所大所打扫打扫多aaaaaaaaaaa挨打是大奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥奥"
      }
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
    t.getKeyValueByKeyType()
    t.getCourseList()
    // t.getSuitCourseList()
  },

  // 跳转课程分类
  gototype(e){
    var t = this
    wx.navigateTo({
      url:'/course/pages/type/index?type='+e.currentTarget.dataset.type
    })
  },
  gotoinfo(e){
    var t = this
    wx.navigateTo({
      url:'/course/pages/info/index?id='+e.currentTarget.dataset.id
    })
  },
  // 获取排序类型
  getKeyValueByKeyType(){
    var t = this,
    data = {
      dict_type:"CourseType"
    }
   $api.getKeyValueByKeyType(data).then(res=>{
     console.log(res)
     t.setData({
      typeList:res.data
     })
   })
  },
   // 获取推荐列表
   getCourseList(){
    var t = this,
    data={
      pageNo:1,
    }
    $api.getRecommendCourseList(data).then(res=>{
      console.log(res)
      t.setData({
        courseList:res.data
      })
    })
   },
   // 获取适合课程列表
  getSuitCourseList(){
    var t = this,
    data = {
      member_id:wx.getStorageSync('user').member_id
    }
    $api.getSuitCourseList(data).then(res=>{
      console.log(res)
    })
  },
  gotocoursesearch(){
    var t = this
    wx.navigateTo({
      url: '/pages/course/search/index',
    })
  }
>>>>>>> 1c9ce1fdc7fcbf1a028b999eb3cd07f698a8a329
})